package edu.hrbu.spring.service.impl;

import edu.hrbu.spring.dao.ActDao;
import edu.hrbu.spring.pojo.Act;
import edu.hrbu.spring.service.IsolationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author 徐登宇
 */
@Service
public class IsolationServiceImpl implements IsolationService {

    @Resource(name = "actDaoImpl")
    private ActDao actDao;


    @Override
    @Transactional
    // 该方法执行保存
    public boolean save(Act act) {
        return actDao.insert(act) == 1;
    }

    @Override
    @Transactional(timeout = 10)
    public Integer selectById(int id) {
        try {
            Thread.sleep(1000*8);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return actDao.selectByNo(id);
    }
}
